package com.masterclient.app.modules.cart.adapter;

import android.content.Context;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.eoner.baselibrary.utils.ScreenUtils;
import com.eoner.baselibrary.utils.ViewTransformUtil;
import com.masterclient.app.R;
import com.masterclient.app.modules.cart.beans.DealerProductsItemBean;
import jp.wasabeef.glide.transformations.RoundedCornersTransformation;

/**
 * 作者：hxm
 * 创建时间：2017/8/4 17:24
 * 功能说明：
 */
public class ShopCartCollectImageAdapter extends BaseQuickAdapter<DealerProductsItemBean, BaseViewHolder> {

    private Context mContent;

    ShopCartCollectImageAdapter(Context mContent) {
        super(R.layout.item_shop_cart_collect_image);
        this.mContent = mContent;
    }

    @Override
    protected void convert(BaseViewHolder helper, DealerProductsItemBean item) {
        ImageView image = helper.getView(R.id.image);
        TextView tvNum = helper.getView(R.id.tv_num);

        tvNum.setText(String.format("×%s", item.num));
        ViewGroup.LayoutParams params = helper.itemView.getLayoutParams();
        params.width = (ScreenUtils.getScreenWidth()-ScreenUtils.dp2px(105))/4;
        params.height = (ScreenUtils.getScreenWidth()-ScreenUtils.dp2px(105))/4;
        helper.itemView.setLayoutParams(params);
        ViewTransformUtil.glideImageView(mContent, item.image, image,
                new RoundedCornersTransformation(ScreenUtils.dp2px(4), 0),
                R.mipmap.defaults);
    }
}
